#include "swmtaskmodel.h"

SWMTaskModel::SWMTaskModel()
{

}

int SWMTaskModel::getModelID(QString model_name)
{
    QSqlQuery query;
    if(!query.exec(QString("select ModelID from SWM_TaskModel where ModelName='%1'").arg(model_name)))
    {
        qWarning()<<query.lastError().text();
        return -1;
    }
    else {
        if(query.first())
        {
            int modelID = query.value("ModelID").toInt();
            return modelID;
        }
    }
    return -3;
}

QString SWMTaskModel::getModelName(int id)
{
    QSqlQuery query;
    if(!query.exec(QString("select ModelName from SWM_TaskModel where ModelID ='%1'").arg(id)))
    {
        qWarning()<<query.lastError().text();
        return "-1";
    }
    else {
        if(query.first())
        {
            QString modelName = query.value("ModelName").toString();
            return modelName;
        }
    }
    return "-3";
}
